package com.derbysoft.synxisadapter.dswitch2.service.impl;

import org.springframework.ws.transport.http.HttpUrlConnectionMessageSender;

import java.io.IOException;
import java.net.HttpURLConnection;

public class MessageSenderImpl extends HttpUrlConnectionMessageSender {
    private static final int DEFAULT_CONNECTION_TIMEOUT_MILLISECONDS = (60 * 1000);
    private static final int DEFAULT_READ_TIMEOUT_MILLISECONDS = (60 * 1000);

    private int readTimeout = DEFAULT_READ_TIMEOUT_MILLISECONDS;
    private int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT_MILLISECONDS;

    @Override
    protected void prepareConnection(HttpURLConnection connection) throws IOException {
        super.prepareConnection(connection);
        connection.setReadTimeout(readTimeout);
        connection.setConnectTimeout(connectionTimeout);
    }

    public void setReadTimeout(int readTimeout) {
        this.readTimeout = readTimeout;
    }

    public void setConnectionTimeout(int connectionTimeout) {
        this.connectionTimeout = connectionTimeout;
    }
}
